from selenium.webdriver.common.by import By
import time

from web import DButils


class Mregister:
    def register(self, driver, username, password, repassword):
        driver.find_element(By.ID, "username").send_keys(username)
        driver.find_element(By.ID, "password").send_keys(password)
        driver.find_element(By.ID, "repassword").send_keys(repassword)
        driver.find_element(By.ID, "login_btn").click()
        time.sleep(1)

    def get_result(self, driver, username):
        sql = "select * from user where username=%s"
        params = [username]
        result = [len(DButils.select(sql, params)), driver.title]
        return result
